home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2534 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.9 KB  |  57 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!marnold
  3. From: marnold@netcom.com (Matt Arnold)
  4. Subject: Re: forward referencing in Borland 4.52
  5. Message-ID: <marnoldDLD928.70@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <4dkfk2$e4v@cloner3.netcom.com>
  8. Date: Thu, 18 Jan 1996 07:34:56 GMT
  9. Sender: marnold@netcom9.netcom.com
  10.  
  11. regmia@ix.netcom.com writes:
  12.  
  13.  
  14.  
  15. >Does anyone know how to CORRECTLY create a forward reference to
  16. >class.
  17.  
  18. >For those of you who may not understand what I am referring to:
  19.  
  20. >Forward referencing of a class means to declare a variable of a class
  21. >type and be able to use that variable BEFORE the class is actually
  22. >defined.
  23.  
  24.  
  25. >Please some one help me!!
  26. >E-Mail me at regmia@ix.netcom.com because I don't come here but once a
  27. >week.
  28.  
  29. class Bar;      // this is forward reference
  30.  
  31. class Foo
  32.    {
  33.    Bar* pBar;   // here, this is legal because of the forward reference
  34.    Bar& rBar;   // again, this is legal
  35.  
  36.                 // if there were no "class Bar;" above, both Bar variable
  37.                 // declarations above would be illegal
  38.  
  39.    Bar  bar;    // ILLEGAL!  you can only use forward references for 
  40.                 // pointer or reference member variables, not embedded 
  41.                 // class members 
  42.    };
  43.  
  44. class Bar       // here, I finally delcare/define Bar AFTER having referred 
  45.    {            // to it in Foo
  46.    };
  47.  
  48.  
  49. Regards,
  50. -------------------------------------------------------------------------
  51. Matt Arnold                       |        | ||| | |||| |  | | || ||
  52. marnold@netcom.com                |        | ||| | |||| |  | | || ||
  53. Boston, MA                        |      0 | ||| | |||| |  | | || ||
  54. 617.389.7384 (h) 617.576.2760 (w) |        | ||| | |||| |  | | || ||
  55. C++, MIDI, Win32/95 developer     |        | ||| 4 3 1   0 8 3 || ||
  56. -------------------------------------------------------------------------
  57.